﻿namespace CommonLibrary.Models
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using BLToolkit.Data;
    using BLToolkit.Data.Linq;

    public enum CommonOption
    {
        Read = 1,
        ReadWrite = 3
    }

    public class CommonDatabase : DbManager
    {
        public const string ReaderConfigure = "ReaderDatabase";
        public const string WriterConfigure = "WriterDatabase";

        public CommonDatabase()
            : base(GetConfigure(CommonOption.Read))
        {
        }

        public CommonDatabase(CommonOption option)
            : base(GetConfigure(option))
        {
        }

        public Table<sys_Application> sys_Application { get { return this.GetTable<sys_Application>(); } }
        public Table<sys_Menu> sys_Menu { get { return this.GetTable<sys_Menu>(); } }
        public Table<sys_Org> sys_Org { get { return this.GetTable<sys_Org>(); } }
        public Table<sys_Position> sys_Position { get { return this.GetTable<sys_Position>(); } }
        public Table<sys_Role> sys_Role { get { return this.GetTable<sys_Role>(); } }
        public Table<sys_RoleMenu> sys_RoleMenu { get { return this.GetTable<sys_RoleMenu>(); } }
        public Table<sys_User> sys_User { get { return this.GetTable<sys_User>(); } }
        public Table<sys_UserInfo> sys_UserInfo { get { return this.GetTable<sys_UserInfo>(); } }
        public Table<sys_UserOrgPosition> sys_UserOrgPosition { get { return this.GetTable<sys_UserOrgPosition>(); } }
        public Table<sys_UserRole> sys_UserRole { get { return this.GetTable<sys_UserRole>(); } }
        public Table<sys_RolePermission> sys_RolePermission { get { return this.GetTable<sys_RolePermission>(); } }


        public Table<wf_Field> wf_Field { get { return this.GetTable<wf_Field>(); } }
        public Table<wf_FieldInstance> wf_FieldInstance { get { return this.GetTable<wf_FieldInstance>(); } }
        public Table<wf_FieldControl> wf_FieldControl { get { return this.GetTable<wf_FieldControl>(); } }
        public Table<wf_Flow> wf_Flow { get { return this.GetTable<wf_Flow>(); } }
        public Table<wf_FlowInstance> wf_FlowInstance { get { return this.GetTable<wf_FlowInstance>(); } }
        public Table<wf_Form> wf_Form { get { return this.GetTable<wf_Form>(); } }
        public Table<wf_FormInstance> wf_FormInstance { get { return this.GetTable<wf_FormInstance>(); } }
        public Table<wf_Node> wf_Node { get { return this.GetTable<wf_Node>(); } }
        public Table<wf_NodeInstance> wf_NodeInstance { get { return this.GetTable<wf_NodeInstance>(); } }
        public Table<wf_Transition> wf_Transition { get { return this.GetTable<wf_Transition>(); } }
        public Table<wf_Dictionary> wf_Dictionary { get { return this.GetTable<wf_Dictionary>(); } }
        public Table<wf_RoleFlow> wf_RoleFlow { get { return this.GetTable<wf_RoleFlow>(); } }
        public Table<wf_Table> wf_Table { get { return this.GetTable<wf_Table>(); } }
        public Table<wf_Column> wf_Column { get { return this.GetTable<wf_Column>(); } }
        public Table<wf_Firewall> wf_Firewall { get { return this.GetTable<wf_Firewall>(); } }

        public Table<wf_Workflow> wf_Workflow { get { return this.GetTable<wf_Workflow>(); } }

        public static string GetConfigure(CommonOption option)
        {
            return option == CommonOption.ReadWrite ? WriterConfigure : ReaderConfigure;
        }
    }
}
